import { request } from "@/utils/request";
import type {
  DeleteParams,
  PersonParams,
  QueryByIdResult,
  QueryParams,
  QueryResult,
} from "./typing";
import type { PageResult, ResponseBody } from "@/api/typing";

/**新增人员 */
export const add = (params: PersonParams) => {
  return request.post<PersonParams, ResponseBody>("/person/add", params);
};

/**修改人员 */
export const update = (params: PersonParams) => {
  return request.put<PersonParams, ResponseBody>("/person/update", params);
};

/**分页查询人员 */
export const queryByPage = (params: QueryParams) => {
  return request.get<QueryParams, ResponseBody<PageResult<QueryResult>>>(
    "/person/page",
    { params }
  );
};

/**删除人员 */
export const del = (params: DeleteParams) => {
  return request.delete<DeleteParams, ResponseBody>("/person/delete", {
    params,
  });
};

/**查询单个人员 */
export const queryById = (personId: string) => {
  return request.get<string, ResponseBody<QueryByIdResult>>("/person/id", {
    params: { personId },
  });
};
